package cn.getech.data.development.controller.api;

import cn.getech.data.development.api.WorkMenuApi;
import cn.getech.data.development.dto.JobCronDto;
import cn.getech.data.development.dto.JobRestDto;
import cn.getech.data.development.entity.WorkMenu;
import cn.getech.data.development.service.IWorkMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName JobInfoApiController
 * @Description TODO
 * @Author Getech
 * @Date 2020/12/24 11:46
 */
@RestController
public class WorkMenuApiController implements WorkMenuApi {

    @Autowired
    private IWorkMenuService iWorkMenuService;


    @Override
    public JobCronDto getCronTypeByJobId(Integer jobInfoId) {
        return iWorkMenuService.getCronTypeByJobId(jobInfoId);
    }

    @Override
    public JobCronDto getCronTypeByDepId(Integer jobDepId) {
        return iWorkMenuService.getCronTypeByDepId(jobDepId);
    }

    @Override
    public String getJobLayOozieId(Long workMenuDepId) {
        return iWorkMenuService.getJobLayOozieId(workMenuDepId);
    }

    @Override
    public String syncRunWorkJob(JobRestDto jobRestDto) {
        if(null == jobRestDto){
            return "-1";
        }
        String depOOzieId = jobRestDto.getDepOOzieId();
        Long jobId = jobRestDto.getJobId();
        return iWorkMenuService.syncRunWorkJob(jobId,depOOzieId);
    }

    @Override
    public WorkMenu getById(Long workMenuId) {
        return iWorkMenuService.getById(workMenuId);
    }
}
